<?php

namespace Controller\Article;

class Detail extends \Controller\Base {

    public function actionIndex() {
        $id = $this->getInt('id');
        $detail = \Data\Article::instance()->getArticleById($id);
        if (!$detail) {
            $this->throwException('文章未找到');
        }
        $categoryId = $detail['CategoryId'];
        $info = \Data\Category::instance()->getParentInfoById($categoryId);
        $this->setCurrentMenu(array(
            isset($info[0]) ? $info[0]['CategoryId'] : 0,
            isset($info[1]) ? $info[1]['CategoryId'] : 0,
        ));

        $pc = array_shift($info);
        $this->assign('categoryId', $categoryId);
        $this->assign('categoryInfo', $pc);
        $this->assign('detail', $detail);
        $this->display();
    }
}